@extends('d.layout.index')
@section('con')
<div class="mws-panel grid_8">
     <div class="mws-panel-header">
          <span>商品细节做工图添加</span>
     </div>

     <div class="mws-panel-body no-padding">
          <form class="mws-form" action="/admin/goods/updateshowdetail" method="post" enctype="multipart/form-data">
               {{csrf_field()}}
               <input type="hidden" name="gid" value="{{$gid}}">
               <div style="margin-left:400px;padding-top:10px;color:blue">
                    <label class="mws-form-label">编辑细节做工图</label>          
               </div>
               <div class="d" style="display:none">
                    <div class="mws-form-inline">
                         <div class="mws-form-row">
                              <label class="mws-form-label">图片</label>
                              <div class="mws-form-item">
                                   <input type="file" name='d0' class="small">
                              </div>
                         </div>                   
                    </div>
                    <div class="mws-form-inline">
                         <div class="mws-form-row">
                              <label class="mws-form-label">序列号</label>
                              <div class="mws-form-item">
                                  <input type="text" name='d00' class="small">
                              </div>
                         </div>                   
                    </div>
               </div>
               @foreach($list as $k => $v) 
               <div class="d">
                    <div class="mws-form-inline">
                         <div class="mws-form-row">
                              <label class="mws-form-label">图片</label>
                              <div class="mws-form-item">
                                   <img src="/goods/pic/{{$v['pic']}}" style="width:100px" alt=""><br>
                                   <input type="file" name='pic{{$k + 1}}' class="small">
                              </div>
                         </div>                   
                    </div>
                    <div class="mws-form-inline">
                         <div class="mws-form-row">
                              <label class="mws-form-label">序列号</label>
                              <div class="mws-form-item">
                                  <input type="text" name='order{{$k + 1}}' class="small" value="{{$v['order']}}">
                              </div>
                         </div>                   
                    </div>
               </div>
               @endforeach
               <div class="mws-form-inline" id="s">
                    <div class="mws-form-row">
                         <button class="btn" id="btn" type="button">添加图片</button>
                    </div>
               </div>
               <div class="mws-button-row">
                    <input type="submit" value="修改" class="btn btn-danger">
                    <input type="reset" value="重置" class="btn ">
               </div>
          </form>
     </div>         
</div>
<script type="text/javascript" src="/d/js/libs/jquery-1.8.3.js"></script>
<script type="text/javascript">
     var num = $('input[class=small]:last').attr('name');
     num = Number(num.substr(-1,1)) + 1;
     $('#btn').click(function() {  
          if(num < 6) {
               var div = $('.d:first').clone();
               div.css('display','block');
               div.insertBefore($('#s'));
               div.find('input[name=d0]').attr('name','pic' + num).val('');
               div.find('input[name=d00]').attr('name','order' + num).val('');
               num++;
          }
          
          return false;
     });
</script>
@endsection